
package com.springboot;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.springboot.service.UserService;

@SpringBootApplication(exclude = JtaAutoConfiguration.class)
@MapperScan("com.springboot.mapper")
class BaseApplication implements ApplicationContextAware {

	private static AnnotationConfigApplicationContext ctx;

	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ctx = (AnnotationConfigApplicationContext) applicationContext;
	}

	public static void main(String[] args) {
		SpringApplication.run(BaseApplication.class, args);
		System.out.println("启动成功");
		UserService userService = (UserService) ctx.getBean("userService");
		System.out.println(userService.userAddTest());
		System.out.println(userService.upcAddTest());
	}
}
